//
// Created by fanghr on 18-3-30.
//

#ifndef NEF_BACKEND_THREAD_MAT_H
#define NEF_BACKEND_THREAD_MAT_H

#include <pthread.h>
#include <opencv2/opencv.hpp>

class thread_mat {
public:
    struct {
        cv::Mat mat_raw;
        bool is_raw_data_ready;
        pthread_rwlock_t rwlock_raw;
        pthread_t thread_raw_getter;
    } raw;

    struct {
        cv::Mat mat_after_preproc;
        bool is_after_pre_comp_data_ready;
        pthread_rwlock_t rwlock_preproc;
        pthread_t thread_preproc;
    } after_preproc;

    struct {
        cv::Mat mat_gray;
        bool is_gray_mat_ready;
        pthread_rwlock_t rwlock_to_gray;
        pthread_t thread_to_gray;
    } to_gray;

    bool is_run;
    int device;

    thread_mat(int dev);

    ~thread_mat();

    int run();

    int stop();
};

#endif //NEF_BACKEND_THREAD_MAT_H
